/**
 * Created by jackliu on 15/12/4.
 */
var co = require('co');
var OSS = require('ali-oss');
var path = require('path');
var fs = require('fs');
var request = require('request');
var CommonUtil = require('./CommonUtil');
var FileUtil = require('./FileUtil');
var CONFIG = require('../config');


var client_image = new OSS({
    region:CONFIG.DEBUG==1?CONFIG.QN2OSS_REGION:CONFIG.QN2OSS_REGION_INTERNAL,
    accessKeyId: CONFIG.ACCESS_KEY_ID,
    accessKeySecret: CONFIG.ACCESS_KEY_SECRET,
    bucket:CONFIG.BUCKET_ITBOUR_IMAGE
});

var client_back = new OSS({
    region: CONFIG.DEBUG==1?CONFIG.QN2OSS_REGION:CONFIG.QN2OSS_REGION_INTERNAL,
    accessKeyId: CONFIG.ACCESS_KEY_ID,
    accessKeySecret: CONFIG.ACCESS_KEY_SECRET,
    bucket:CONFIG.BUCKET_ITBOUR_BACK
});

var client_user = new OSS({
    region: CONFIG.DEBUG==1?CONFIG.QN2OSS_REGION:CONFIG.QN2OSS_REGION_INTERNAL,
    accessKeyId: CONFIG.ACCESS_KEY_ID,
    accessKeySecret: CONFIG.ACCESS_KEY_SECRET,
    bucket:CONFIG.BUCKET_ITBOUR_USER
});

var client_generate = new OSS({
    region: CONFIG.DEBUG==1?CONFIG.QN2OSS_REGION:CONFIG.QN2OSS_REGION_INTERNAL,
    accessKeyId: CONFIG.ACCESS_KEY_ID,
    accessKeySecret: CONFIG.ACCESS_KEY_SECRET,
    bucket:CONFIG.BUCKET_ITBOUR_GENERATE
});

var client_map = {};
client_map[CONFIG.BUCKET_ITBOUR_IMAGE]=client_image; // for test
client_map[CONFIG.BUCKET_ITBOUR_BACK]=client_back;// 后台上传的图片、图形的图片
client_map[CONFIG.BUCKET_ITBOUR_USER]=client_user;//  用户上传的音视频、图片
client_map[CONFIG.BUCKET_ITBOUR_GENERATE]=client_generate;// 生成结果：模版缩略图、排版结果、视频抽图等




export  =  OSSMgr;

class  OSSMgr{
    // 获取阿里云oss的内网的client
    // 参数：bucket: bucket-name
    public static get (bucket) {
        return client_map[bucket];
    }

}

